package wenjie.chen.transfer.commandHandler.impl;

import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import wenjie.chen.transfer.command.TransferCommand;
import wenjie.chen.transfer.commandHandler.ITransferCommandHandler;
import wenjie.chen.transfer.dao.AccountDao;

@Log4j
@Component("transferCommandHandlerCancel")
@Transactional
@RequiredArgsConstructor
public class TransferCommandHandlerCancel implements ITransferCommandHandler {
    @NonNull
    private final AccountDao accountDao;

    @Override
    public void transfer(TransferCommand command) {
        accountDao.cancelDecreaseAmount(command.getRemitterAccountId(), command.getAmount());
    }
}
